Skip to main content

Setting Up The Breathalyzer System

Out of the Box

By default, r14-evidence is designed to integrate with qb-smallresources without any further configuration or modification to the script. The way this is handled by default is through the 'evidence:client:SetStatus' client-side networked event handler used by the original qb-policejob/client/evidence.lua. With built in event triggers in qb-smallresources, r14-evidence will receieve SetStatus events with the alcohol tag and automatically use them to increase a player's blood alcohol content by .0015.

Client-side Network Event Handler
RegisterNetEvent('evidence:client:SetStatus', function(statusId, time, abv)
if Config.Breathalyzer and (statusId == 'alcohol' or statusId == 'heavyalcohol') then
TriggerServerEvent('evidence:server:IncreaseBAC', abv or 15) -- increases BAC by .015 or by abv if a third argument is supplied
end

if Config.DrugTesting.Enabled and Config.DrugTesting.UsingQBSR and statusId == 'weedsmell' then
TriggerServerEvent('evidence:server:SetDrugStatus', {drug = 'weed'})
end

if time > 0 and Config.StatusList[statusId] then
if (CurrentStatusList == nil or CurrentStatusList[statusId] == nil) or (CurrentStatusList[statusId] and CurrentStatusList[statusId].time < 20) then
CurrentStatusList[statusId] = {
text = Config.StatusList[statusId],
time = time
}
Config.Functions.Notify(''..CurrentStatusList[statusId].text..'')
end
elseif Config.StatusList[statusId] then
CurrentStatusList[statusId] = nil
end
TriggerServerEvent('evidence:server:UpdateStatus', CurrentStatusList)
end)

If you are using a third-party script to handle your alcohol consumables, we have two options, we can either configure the events it uses in the r14-evidence config, or we can modify the consumables resource to trigger specific events in r14-evidence which will control the BAC of a player. We will examine both options, starting with the simpler method of simply configuring support for the script!

caution

Never make changes to ANY script without making a backup first, you never know what might happen!

Configuring A Third Party Script

r14-evidence Breathalyzer Config
--[[------------ Breathalyzer Config ----------------

This table allows you to set up or completely disable breathalying in this script. Out of the box, r14-evidence provides support for qb-core smallresources through
a built in event handler, and requires set up to use with other frameworks and third party resources. You can use the EventTriggers subfield below to set up
events which will trigger ABV increases for a player that can be tested using the breahtalyzer target option by police characters, or you can follow the guide at
regalonefour.github.io to insert the appropriate event triggers into your consumables or inventory resource in order to trigger the proper ABV increase.

[2] = {
event = 'consumables:server:drinkAlcohol', -- name of the event
type = 'server', -- OPTIONAL, server or client to specify which type of event
alcoholArgPos = 1, -- OPTIONAL, the position of the argument recieved in the event handler
alocholArgSubField = 'item', -- OPTIONAL, if the arg is a table, the subfield you want to check such as in this case arg[1].item
alcoholArgValue = { -- OPTIONAL, the value the argument should be equal to in order to trigger, can either be a value or a table
['beer'] = true,
['vodka'] = 20, -- you can specify a custom ABV by setting the key equal to a value instead of true, in this case it will raise ABV by 0.02 instead of 0.15
},
},

--]]--------------------------------------------------


Config.Breathalyzer = {
Enabled = true, -- set this to true if you want to use the breathalyzer events contained in this script (may require additional setup if not using qb-smallresources)
UsingESX = true, -- set this to true if you are using ESX and want to use the native ESX.setPlayerStatus function to set BAC
EventTriggers = {
[1] = {event = 'hypothetical_consumables:server:consumedrink', type = 'server', alocholArgPos = 2, alocholArgSubField = 'item', alcoholArgValue = 'margarita', cidArgPos = nil},
},
}

Here we can see the Config.Breathalyzer table found in r14-evidence and a brief explanation of how it works. By default, support for ESX and qb-smallresources are included out of the box to handle increasing BAC using the evidence:client:setstatus event for qb-core and the esx:setStatus event for ESX which can be used to apply the drunk status. If we have a third-party script that does not already include support for either of these methods, and it is open-source, we can create a configuration for the breathalyzer subsystem to be triggered when alochol items are used. To use the script in this way, lets go ahead an find an example script to use to set up a configuration, in this case lets use boii-consumables from https://github.com/boiidevelopment/boii-consumables-qb to set up support for it. It is open-source, and will allow us to examine the code for events we can use.

info

Please keep in mind this is specific to this version of boii-consumables, you will need to apply the general concepts from this guide to other scripts, not the exact code.

boii-consumables Alcohol Function
local function Alcohol(itemname)
local player = PlayerPedId()
if Config.Consumables.Alcohol[itemname].dualprops then
Core.Functions.Progressbar('consumables_alcohol', Config.Consumables.Alcohol[itemname].bartext, Config.Consumables.Alcohol[itemname].bartime*1000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = false
}, {
animDict = Config.Consumables.Alcohol[itemname].dict,
anim = Config.Consumables.Alcohol[itemname].animation,
flags = Config.Consumables.Alcohol[itemname].flags
}, {
model = Config.Consumables.Alcohol[itemname].prop,
bone = Config.Consumables.Alcohol[itemname].bones,
coords = Config.Consumables.Alcohol[itemname].coord,
rotation = Config.Consumables.Alcohol[itemname].rotat
}, {
model = Config.Consumables.Alcohol[itemname].prop2,
bone = Config.Consumables.Alcohol[itemname].bones2,
coords = Config.Consumables.Alcohol[itemname].coord2,
rotation = Config.Consumables.Alcohol[itemname].rotat2
}, function()
AlcoholCount = AlcoholCount + Config.Consumables.Alcohol[itemname].alcoholcount
TriggerServerEvent('boii-consumables:sv:RemoveItem', itemname, 1)
TriggerServerEvent(RemoveStress, Config.Consumables.Alcohol[itemname].stress)
TriggerServerEvent('boii-consumables:sv:AddMeta', Config.Consumables.Alcohol[itemname].hunger, Config.Consumables.Alcohol[itemname].thirst)
if Config.Consumables.Alcohol[itemname].shouldreturn then
TriggerServerEvent('boii-consumables:sv:AddItem', Config.Consumables.Alcohol[itemname].returnitem, 1)
end
if AlcoholCount > 3 and AlcoholCount < 7 then -- Edit the amount of alcohol required to trigger drunk effects here
LightDrunk()
elseif AlcoholCount >= 7 then
HeavyDrunk()
end
if (Config.Consumables.Alcohol[itemname].sickchance >= math.random(1, 100)) then
ThrowUp(player, Config.Consumables.Alcohol[itemname].removehealth, Config.Consumables.Alcohol[itemname].stress)
end
end, function() -- Cancel
TriggerEvent('inventory:client:busy:status', false)
TriggerEvent('boii-consumables:notify', Language.Shared['cancelled'], 'primary')
end)
else
Core.Functions.Progressbar('consumables_alcohol', Config.Consumables.Alcohol[itemname].bartext, Config.Consumables.Alcohol[itemname].bartime*1000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = false
}, {
animDict = Config.Consumables.Alcohol[itemname].dict,
anim = Config.Consumables.Alcohol[itemname].animation,
flags = Config.Consumables.Alcohol[itemname].flags
}, {
model = Config.Consumables.Alcohol[itemname].prop,
bone = Config.Consumables.Alcohol[itemname].bones,
coords = Config.Consumables.Alcohol[itemname].coord,
rotation = Config.Consumables.Alcohol[itemname].rotat
}, {}, function()
AlcoholCount = AlcoholCount + Config.Consumables.Alcohol[itemname].alcoholcount
TriggerServerEvent('boii-consumables:sv:RemoveItem', itemname, 1)
TriggerServerEvent(RemoveStress, Config.Consumables.Alcohol[itemname].stress)
TriggerServerEvent('boii-consumables:sv:AddMeta', Config.Consumables.Alcohol[itemname].hunger, Config.Consumables.Alcohol[itemname].thirst)
if Config.Consumables.Alcohol[itemname].shouldreturn then
TriggerServerEvent('boii-consumables:sv:AddItem', Config.Consumables.Alcohol[itemname].returnitem, 1)
end
if AlcoholCount > 3 and AlcoholCount < 7 then -- Edit the amount of alcohol required to trigger drunk effects here
LightDrunk()
elseif AlcoholCount >= 7 then
HeavyDrunk()
end
if (Config.Consumables.Alcohol[itemname].sickchance >= math.random(1, 100)) then
ThrowUp(player, Config.Consumables.Alcohol[itemname].removehealth, Config.Consumables.Alcohol[itemname].stress)
end
end, function() -- Cancel
TriggerEvent('inventory:client:busy:status', false)
TriggerEvent('boii-consumables:notify', Language.Shared['cancelled'], 'primary')
end)
end
end

Here we see the function triggered by the use of alcohol items generates a progress bar, this means that it's possible for a player to begin drinking an item, cancel it, and then not have any drunk status effects applied. This means like drugs, we want to only attempt to use events triggered upon successful COMPLETION of the progressbar. These sections are highlighted above. Lets take a closer look and figure out what we can do.

boii-consumables Successful Alcohol Use Code
    AlcoholCount = AlcoholCount + Config.Consumables.Alcohol[itemname].alcoholcount
TriggerServerEvent('boii-consumables:sv:RemoveItem', itemname, 1)
TriggerServerEvent(RemoveStress, Config.Consumables.Alcohol[itemname].stress)
TriggerServerEvent('boii-consumables:sv:AddMeta', Config.Consumables.Alcohol[itemname].hunger, Config.Consumables.Alcohol[itemname].thirst)
if Config.Consumables.Alcohol[itemname].shouldreturn then
TriggerServerEvent('boii-consumables:sv:AddItem', Config.Consumables.Alcohol[itemname].returnitem, 1)
end
if AlcoholCount > 3 and AlcoholCount < 7 then -- Edit the amount of alcohol required to trigger drunk effects here
LightDrunk()
elseif AlcoholCount >= 7 then
HeavyDrunk()
end
if (Config.Consumables.Alcohol[itemname].sickchance >= math.random(1, 100)) then
ThrowUp(player, Config.Consumables.Alcohol[itemname].removehealth, Config.Consumables.Alcohol[itemname].stress)
end

While we could follow the LightDrunk() and HeavyDrunk() functions to see if there are other places on the client-side we could configure an event for, we can see the triggering of a few server events here that remove the item from the player's inventory when a drink is consumed. Because we can configure server events these are likely going to be our ideal places to configure an event trigger in r14-evidence. We can see that the 'boii-consumables:sv:RemoveItem' removes the alcohol item from our inventory when its used by sending its name to the server. We can use this to set up our config in evidence by checking this value and including it in the AlcoholArgValue value. Lets create a test line for the beer item.

r14-evidence Config For boii-consumables
    Config.Breathalyzer = {
Enabled = true, -- set this to true if you want to use the breathalyzer events contained in this script (may require additional setup if not using qb-smallresources)
UsingESX = true, -- set this to true if you are using ESX and want to use the native ESX.setPlayerStatus function to set BAC
EventTriggers = {
[1] = {event = 'boii-consumables:sv:RemoveItem', type = 'server', alocholArgPos = 1, alcoholArgValue = 'beer'},
},
}

Saving this in our config, we can now restart r14-evidence and attempt to drink a beer. We can enable PrintEventTriggerArgs in our debug variables in order to print the results to our server console as well! We can see that the item name is sent as the first argument, it is a simple string and not a table so we do not need to use the alcoholArgSubfield variable to access it, and we set our alcoholArgValue equal to item name we want to increase BAC. Now when we drink a beer, we should see an increase in our BAC if we use the /selfbreathalyze command from r14-evidence to test our player character while in the server.

Now that we have confirmed this works, we may want to expand it to encompass all our alcohol items! You could create a seperate line in Config.Breathalzyer.EventTriggers for each item, or you can modify the alcoholArgValue to be a table that contains the list of items we want to use. Lets try this, and let's go ahead and indent our table so it is easier to read.

r14-evidence Config For boii-consumables
    Config.Breathalyzer = {
Enabled = true, -- set this to true if you want to use the breathalyzer events contained in this script (may require additional setup if not using qb-smallresources)
UsingESX = true, -- set this to true if you are using ESX and want to use the native ESX.setPlayerStatus function to set BAC
EventTriggers = {
[1] = {
event = 'boii-consumables:sv:RemoveItem',
type = 'server',
alocholArgPos = 1,
alcoholArgValue = {
['beer'] = true,
['vodka'] = 20,
['marg'] = true,
['moonshine'] = 25,
}
},
},
}

Here we have now defiend beer, vodka, marg, and moonshine as alcohol items checked for by our breathalyzer event. We can either set these items equal to TRUE to increase the player's BAC by the standard 0.015 as the script will assign a value of 15 in the absence of a custom defined ABV, or we can set this equal to a number between 1 and 1000. In this case we can see we have set moonshine equal to 25 or a 0.025 increase in BAC and vodka now increases BAC by 0.02 or 20 units instead of 15. We must add all the items we want to trigger a BAC increase if we choose to take this route for our config, or we can choose to edit our script to integrate it with r14-evidence.

Integrating A Third Party Script

If you do not use qb-smallresources, and your consumable script that you use for alcohol does not come with built in triggers for the 'evidence:client:SetStatus' network event, you or a dev for your server can add these events if you have access to the source code! If you aren't able to modify the resource directly due to escrow, consider asking the developer to add it themselves. In order to understand where we want to make our edits, lets take a look at how qb-smallresrouces handles consumables and where it triggers this event.

Server-side Create Useable Item Function
QBCore.Functions.CreateUseableItem("beer", function(source, item)
TriggerClientEvent("consumables:client:DrinkAlcohol", source, item.name)
end)

Here, we can see the item 'beer' being made useable by the above function, it triggers a client-side event in the consumables.lua, and then ends. If this was a script you were attempting to modify, adding the evidence:client:SetStatus event trigger here would automatically set the increase in BAC the moment an item is used. We should follow this event to see how the item is used before adding it.

Client-side Network Event Handler
RegisterNetEvent('consumables:client:DrinkAlcohol', function(itemName)
TriggerEvent('animations:client:EmoteCommandStart', {"drink"})
QBCore.Functions.Progressbar("snort_coke", "Drinking liquor..", math.random(3000, 6000), false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
TriggerEvent('animations:client:EmoteCommandStart', {"c"})
TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items[itemName], "remove")
TriggerServerEvent("consumables:server:drinkAlcohol", itemName)
TriggerServerEvent("consumables:server:addThirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + ConsumablesAlcohol[itemName])
TriggerServerEvent('hud:server:RelieveStress', math.random(2, 4))
alcoholCount += 1
if alcoholCount > 1 and alcoholCount < 4 then
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
elseif alcoholCount >= 4 then
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
end

end, function() -- Cancel
TriggerEvent('animations:client:EmoteCommandStart', {"c"})
QBCore.Functions.Notify("Cancelled..", "error")
end)
end)

Here, in the client-side event triggered by the usage of the 'beer' item, we can see it then invokes the Progress Bar function native to qb-core. Using the comments, we can see that the middle part of the code block contains a function which is triggered when the progress bar is completed, and a little lower, the function that is triggered if the progress bar is canceled. Since we only want to increase the BAC of a player who actually drinks the beer, this is the best spot for the 'evidence:client:SetStatus' event trigger to be placed.

We can similarly trigger this same event from the server-side if needed. If you have a resource that handles consumables differently, you may need to search for a place in a server function or event handler. Let's return to the example we used in the configuration guide and examine our event from boii-consumables-qb to see where we may need to make an edit to our resource to integreate it with r14-evidence.

boii-consumables Alcohol Function
local function Alcohol(itemname)
local player = PlayerPedId()
if Config.Consumables.Alcohol[itemname].dualprops then
Core.Functions.Progressbar('consumables_alcohol', Config.Consumables.Alcohol[itemname].bartext, Config.Consumables.Alcohol[itemname].bartime*1000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = false
}, {
animDict = Config.Consumables.Alcohol[itemname].dict,
anim = Config.Consumables.Alcohol[itemname].animation,
flags = Config.Consumables.Alcohol[itemname].flags
}, {
model = Config.Consumables.Alcohol[itemname].prop,
bone = Config.Consumables.Alcohol[itemname].bones,
coords = Config.Consumables.Alcohol[itemname].coord,
rotation = Config.Consumables.Alcohol[itemname].rotat
}, {
model = Config.Consumables.Alcohol[itemname].prop2,
bone = Config.Consumables.Alcohol[itemname].bones2,
coords = Config.Consumables.Alcohol[itemname].coord2,
rotation = Config.Consumables.Alcohol[itemname].rotat2
}, function()
AlcoholCount = AlcoholCount + Config.Consumables.Alcohol[itemname].alcoholcount
TriggerServerEvent('boii-consumables:sv:RemoveItem', itemname, 1)
TriggerServerEvent(RemoveStress, Config.Consumables.Alcohol[itemname].stress)
TriggerServerEvent('boii-consumables:sv:AddMeta', Config.Consumables.Alcohol[itemname].hunger, Config.Consumables.Alcohol[itemname].thirst)
if Config.Consumables.Alcohol[itemname].shouldreturn then
TriggerServerEvent('boii-consumables:sv:AddItem', Config.Consumables.Alcohol[itemname].returnitem, 1)
end
if AlcoholCount > 3 and AlcoholCount < 7 then -- Edit the amount of alcohol required to trigger drunk effects here
LightDrunk()
elseif AlcoholCount >= 7 then
HeavyDrunk()
end
if (Config.Consumables.Alcohol[itemname].sickchance >= math.random(1, 100)) then
ThrowUp(player, Config.Consumables.Alcohol[itemname].removehealth, Config.Consumables.Alcohol[itemname].stress)
end
end, function() -- Cancel
TriggerEvent('inventory:client:busy:status', false)
TriggerEvent('boii-consumables:notify', Language.Shared['cancelled'], 'primary')
end)
else
Core.Functions.Progressbar('consumables_alcohol', Config.Consumables.Alcohol[itemname].bartext, Config.Consumables.Alcohol[itemname].bartime*1000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = false
}, {
animDict = Config.Consumables.Alcohol[itemname].dict,
anim = Config.Consumables.Alcohol[itemname].animation,
flags = Config.Consumables.Alcohol[itemname].flags
}, {
model = Config.Consumables.Alcohol[itemname].prop,
bone = Config.Consumables.Alcohol[itemname].bones,
coords = Config.Consumables.Alcohol[itemname].coord,
rotation = Config.Consumables.Alcohol[itemname].rotat
}, {}, function()
AlcoholCount = AlcoholCount + Config.Consumables.Alcohol[itemname].alcoholcount
TriggerServerEvent('boii-consumables:sv:RemoveItem', itemname, 1)
TriggerServerEvent(RemoveStress, Config.Consumables.Alcohol[itemname].stress)
TriggerServerEvent('boii-consumables:sv:AddMeta', Config.Consumables.Alcohol[itemname].hunger, Config.Consumables.Alcohol[itemname].thirst)
if Config.Consumables.Alcohol[itemname].shouldreturn then
TriggerServerEvent('boii-consumables:sv:AddItem', Config.Consumables.Alcohol[itemname].returnitem, 1)
end
if AlcoholCount > 3 and AlcoholCount < 7 then -- Edit the amount of alcohol required to trigger drunk effects here
LightDrunk()
elseif AlcoholCount >= 7 then
HeavyDrunk()
end
if (Config.Consumables.Alcohol[itemname].sickchance >= math.random(1, 100)) then
ThrowUp(player, Config.Consumables.Alcohol[itemname].removehealth, Config.Consumables.Alcohol[itemname].stress)
end
end, function() -- Cancel
TriggerEvent('inventory:client:busy:status', false)
TriggerEvent('boii-consumables:notify', Language.Shared['cancelled'], 'primary')
end)
end
end

As before we can see the function triggered by the use of alcohol items generates a progress bar, this means that it's possible for a player to begin drinking an item, cancel it, and then not have any drunk status effects applied. This means like drugs, we want to only attempt to use events triggered upon successful COMPLETION of the progressbar. These sections are highlighted above, but we will take a closer look and add some code that will trigger the status event in r14-evidence!

info

Please keep in mind this is specific to this version of boii-consumables, you will need to apply the general concepts from this guide to other scripts, not the exact code.

boii-consumables Successful Alcohol Use Code
    AlcoholCount = AlcoholCount + Config.Consumables.Alcohol[itemname].alcoholcount
TriggerServerEvent('boii-consumables:sv:RemoveItem', itemname, 1)
TriggerServerEvent(RemoveStress, Config.Consumables.Alcohol[itemname].stress)
TriggerServerEvent('boii-consumables:sv:AddMeta', Config.Consumables.Alcohol[itemname].hunger, Config.Consumables.Alcohol[itemname].thirst)
if Config.Consumables.Alcohol[itemname].shouldreturn then
TriggerServerEvent('boii-consumables:sv:AddItem', Config.Consumables.Alcohol[itemname].returnitem, 1)
end
if AlcoholCount > 3 and AlcoholCount < 7 then -- Edit the amount of alcohol required to trigger drunk effects here
LightDrunk()
elseif AlcoholCount >= 7 then
HeavyDrunk()
end

if AlcoholCount > 0 and alcoholCount < 4 then
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
elseif alcoholCount >= 4 then
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
end
if (Config.Consumables.Alcohol[itemname].sickchance >= math.random(1, 100)) then
ThrowUp(player, Config.Consumables.Alcohol[itemname].removehealth, Config.Consumables.Alcohol[itemname].stress)
end

Here we can see we now check if our AlcoholCount is above 0, which it should always be once this event has triggered, if the player has used less than four alcohol items it will trigger 'evidence:client:SetStatus' with the alochol status, and above 4 it will instead trigger heavyalcohol. By triggering this status we do not need check if the item is an alcohol item because boii-consumnables is handling this logic, and r14-evidence will automatically apply a BAC increase of 0.15 by supplying the default value of 15 units for the ABV.

If say, we want to instead trigger our BAC increase manually, we can follow one of the event triggers in the above code to the server-side of our code, and make a modification there instead to trigger r14-evidence. When we follow this client event to the server, we can insert a TriggerClientEvent() which will allow r14-evidence to register the usage of an alcohol item and then increaes the BAC and apply the status effect.

Server-side Network Event Handler
RegisterServerEvent('boii-consumables:sv:RemoveItem', function(itemremove, amount)
local src = source
local Player = Core.Functions.GetPlayer(src)
if Player.Functions.RemoveItem(itemremove, tonumber(amount)) then
TriggerClientEvent('inventory:client:ItemBox', src, Core.Shared.Items[itemremove], 'remove', tonumber(amount))
end
TriggerClientEvent('evidence:client:SetStatus', source, 'alcohol')
end)

If we only use this event for alcohol items we could simply add a blanket TriggerClientEvent() that will set the status of the player in r14-evidence and thus the BAC incrase, but this event is used for ALL items in boii-consumables so we need to add some extra logic to restrict it to only alcohol items. The config contains a list of alcohol items, and we can simply use the itemname argument to check against it.

In this modified event handler, we now properly check if the item name is in our Config.Consumables.Alcohol table and even add the ability to add a custom ABV field to those items to manually set how much the item will increase the player BAC.

boii-consumables Config
    Alcohol = {
['beer_am'] = {
alcoholcount = 1, -- Amount to increase alcohol count
sickchance = math.random(5,10), -- Chance to be sick if risky = true
removehealth = math.random(5, 8), -- Amount of health to remove if risky = true
hunger = 0, -- Amount of hunger to receive
thirst = math.random(25,40), -- Amount of thirst to receive
stress = math.random(3,6), -- Amount of stress to remove
bartext = 'Drinking A.M..', -- Progress bar text
bartime = math.random(2,5), -- Progress bar time
shouldreturn = true, -- Toggle if item should be returned; false = no return item; true = return item
returnitem = 'empty_glass_bottle', -- Item to return if returns = true
dict = 'mp_player_intdrink', -- Animation dictionary
animation = 'loop_bottle', -- Animation
flags = 49, -- Animation flags
dualprops = false, -- Toggle use of 2 props; false = 1 prop, true = 2 props
prop = 'prop_beer_amopen', -- Prop 1
bones = 60309, -- Bone index 1
coords = vector3(-0.005, 0.00, -0.09), -- Prop coords 1
rotation = vector3(0.0, 0.0, 0.0), -- Prop rotation 1
prop2 = '', -- Prop 2
bones2 = '', -- Bone index 2
coords2 = '', -- Prop coords 2
rotation2 = '', -- Prop rotation 2
ABV = 30,
},
Server-side Network Event Handler
RegisterServerEvent('boii-consumables:sv:RemoveItem', function(itemremove, amount)
local src = source
local Player = Core.Functions.GetPlayer(src)
if Player.Functions.RemoveItem(itemremove, tonumber(amount)) then
TriggerClientEvent('inventory:client:ItemBox', src, Core.Shared.Items[itemremove], 'remove', tonumber(amount))
end
if Config.Consumables.Alcohol[itemremove] then
local count = Config.Consumables.Alcohol[itemremove].alcoholcount
local customABV = Config.Consumables.Alcohol[itemremove].ABV

TriggerClientEvent('evidence:client:SetStatus', source, 'alcohol', customABV or count and 15 * count)
end
end)

Now if there is a ABV value defined in the config for that alcohol item, the script will send it as the ABV argument, or if there is not and the alcoholcount variable is present it will use it to calculate the ABV. In this case beer_am has an alcoholcount of 1 and thus would only be 15. However, if we made a moonshine item with an alcoholcount of 3 in this script, it would then send 45 to r14-evidence instead and raise the ABV of our player by 0.045 instead of the standard 0.015.